package Day017_缓冲流_转换流_序列化流_打印流.ZuoYe;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * @author zhangyan
 * @date 2020/5/9 19:23
 */
public class Test4 {
    public static void main(String[] args) throws Exception{

        //创建高效字节输入流,关联数据源文件路径
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Demo02\\aaa\\aaa.png"));

        //创建高效字节输出流
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("D:\\aaa.png"));

        //创建字节数组
        byte[] bytes = new byte[8*1024];

        //以字节数组形式读取
        //定义变量存储每次读取的数据
        int len;
        while ((len = bis.read()) != -1){
            //边读边写
            bos.write(len);
        }
        //关流
        bos.close();
        bis.close();
    }
}
